# _*_coding=utf-8 _*_
"""
@author :   xh
@date   :   2023/11/21 19:00
"""
from utils.make_html import make_html

if __name__ == '__main__':
    # 解方程
    # raw = {"latexList": [r"\dfrac{t}{3}=7"], "label": "解方程", "ext": {}}
    # raw = {"latexList": [r"(2\dfrac{1}{4})g=\dfrac{1}{2}"], "label": "解方程", "ext": {}}
    # raw = {"latexList": [r"6(1-x)-5(x-2)=2(2x+3)"], "label": "解方程", "ext": {}}
    # raw = {"latexList": [r"3(r+1)-5=3r-2"], "label": "解方程", "ext": {}}
    # raw = {"latexList": ["(x-4)^2=121"], "label": "解方程", "ext": {}}
    # raw = {"latexList": ["y^{2}=64"], "label": "解方程", "ext": {}}
    # raw = {"latexList": ["(z+7)^{2}=-49"], "label": "解方程", "ext": {}}
    # raw = {"latexList": ["(z+7)^{2}=-49"], "label": "解方程", "ext": {"query": "complex number"}}
    # raw = {"latexList": ["(5 x-1)^{2}+6=0"], "label": "解方程", "ext": {"query": "complex number"}}
    # raw = {"latexList": ["y^2+6y+2=0"], "label": "解方程", "ext": {}}
    # raw = {"latexList": ["x^{2}-5.6 x+1.1=0"], "label": "解方程", "ext": {}}
    # raw = {"latexList": [r"-2.2 x=-1-0.9(x+9)"], "label": "解方程", "ext": {}}
    raw = {"latexList": [r"<p>$3.6\times2002\dfrac{2}{5}+2014.9\times6\dfrac{2}{5}$</p>"], "label": "计算", "ext": {}}
    result = solve(raw)
    print("-----------解题过程-----------")
    print(result)
    print(result['answer'])
    print(result['stepResult'])
    tmpRs = ''
    for step in result['stepResult']:
        if step['explain']:
            step_e = ""
            for item in step['explain']:
                if item['type'] == 'latex':
                    step_e += " " + "$" + item['text'] + "$"
                else:
                    step_e += " " + item['text']
            tmpRs += "<p>%s</p>" % step_e
            print(step_e)
        if step['formula']:
            step_f = ""
            for item in step['formula']:
                if item['type'] == 'latex':
                    step_f += " " + "$" + item['text'] + "$"
                else:
                    step_f += item['text']
            tmpRs += "<p>%s</p>" % step_f
            print(step_f)
    make_html(["<p>$"+",".join(raw['latexList'])+"$</p>", tmpRs], 'Test/test.html')
